package com.begye.smartloan.apptest.outsuccess

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.begye.smartloan.apptest.R
import com.begye.smartloan.apptest.databinding.AtOutSuccessBinding
import com.begye.smartloan.apptest.homebefore.HomeBeforeActivity
import com.begye.smartloan.apptest.kefu.KeFuDialogFragment
import com.begye.smartloan.apptest.tool.addTouch
import com.util.utillib.extend.IntentFlagMode
import com.util.utillib.extend.toNextActivity


@SuppressLint("CustomWelcomeScreen")
class OutSuccessActivity : AppCompatActivity() {

    private lateinit var _binding: AtOutSuccessBinding

    @SuppressLint("NotifyDataSetChanged")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        _binding = AtOutSuccessBinding.inflate(layoutInflater)
        setContentView(_binding.root)

        configUIState()
        configUIEvent()
    }

    private fun configUIState() {

    }

    private fun configUIEvent() {

        _binding.atOutSuccessNar.initConfig(
            text = "",
            leftResId = R.drawable.dres_39,
            rightResId = R.drawable.dres_84,
            hideLeftRes = true
        ) {
            if (0 == it) {
                //
                toNextActivity(
                    activity = HomeBeforeActivity::class.java,
                    mode = IntentFlagMode.SINGLE_TOP
                )
            } else if (1 == it) {
                val dialog = KeFuDialogFragment()
                dialog.showNow(supportFragmentManager, "kefu")
            }
        }

        _binding.atOutSuccessCommit.setOnClickListener {
            toNextActivity(
                activity = HomeBeforeActivity::class.java,
                mode = IntentFlagMode.SINGLE_TOP
            )
        }
    }

    override fun onResume() {
        super.onResume()

        addTouch(type = this.javaClass.simpleName, isOpen = true)
    }

    override fun onPause() {
        super.onPause()

        addTouch(type = this.javaClass.simpleName, isComplete = true)
    }
}

